//
//  LMJCollectionViewCell.m
//  EPA
//
//  Created by lanou3g on 16/4/19.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "LMJCollectionViewCell.h"

@interface LMJCollectionViewCell ()

@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UILabel *titleLable;

@end
@implementation LMJCollectionViewCell

- (void)awakeFromNib {
    // Initialization code
}
- (void)setModel:(LMJHomeModel *)model {
    if (_model != model) {
        _model = model;
    }
}
- (void) layoutSubviews {
    self.titleLable.text = self.model.name;
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.model.coverimg]];
    NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession]dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        if (data) {
            dispatch_async(dispatch_get_main_queue(), ^{
                self.imageView.image = [UIImage imageWithData:data];
            });
        }
    }];
    [dataTask resume];
}

@end
